home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / snip9_91.arc / CHANGPRN.C < prev    next >
C/C++ Source or Header  |  1991-09-17  |  864b  |  46 lines

  1. /*
  2. **  change_prn()
  3. **
  4. **  A function to change the standard printer device for the duration
  5. **  of a program. Valid new device codes are:
  6. **
  7. **      0 - LPT1
  8. **      1 - LPT2
  9. **      2 - LPT3
  10. **      3 - COM1
  11. **      4 - COM2
  12. **      5 - CON
  13. */
  14.  
  15. #include <stdio.h>
  16.  
  17. int change_prn(int device)
  18. {
  19.       char *newdev;
  20.  
  21.       switch (device)
  22.       {
  23.       case 0:
  24.             newdev = "LPT1";
  25.             break;
  26.       case 1:
  27.             newdev = "LPT2";
  28.             break;
  29.       case 2:
  30.             newdev = "LPT3";
  31.             break;
  32.       case 3:
  33.             newdev = "COM1";
  34.             break;
  35.       case 4:
  36.             newdev = "COM2";
  37.             break;
  38.       case 5:
  39.             newdev = "CON";
  40.             break;
  41.       default:
  42.             return -1;
  43.       }
  44.       return (NULL == freopen(newdev, "w", stdprn));
  45. }
  46.